/* 
 * Uft8EncodingFilter.java 
 *  
 * 1.0
 * 
 * 2013/07/20
 *  
 * Copyright (c) 2013 FPT Software. 
 * 
 * Modification Logs:  
 * DATE             AUTHOR     DESCRIPTION  
 * --------------------------------------------------------  
 * 2013/07/20       TrongND    Create
 */

package com.jms.fu.common;

import java.io.IOException;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;

/**
 * The UTF-8 filter, using to set character encoding for data of request
 * 
 * @author Framework Team
 * 
 */
public class Utf8EncodingFilter implements Filter {
	@Override
	public void init(FilterConfig chain) throws ServletException {
	}

	@Override
	public void doFilter(ServletRequest request, ServletResponse response,
			FilterChain chain) throws IOException, ServletException {

		// set URF-8 encoding
		request.setCharacterEncoding("UTF-8");
		// do filter
		chain.doFilter(request, response);
	}

	@Override
	public void destroy() {
	}
}
